package com.wx.callback.impl;

import com.wx.callback.CallBack;
import com.wx.callback.Data;
import com.wx.callback.Fetcher;
import lombok.extern.slf4j.Slf4j;

/**
 * 访问者
 *
 * @author wangxun
 * @date 2023/03/15
 */
@Slf4j
public class MyFetcher implements Fetcher {

    private Data data;

    public MyFetcher(Data data) {
        this.data = data;
    }

    @Override
    public void FetchData(CallBack callBack) {
        try {
            // 执行错误编码
            int i = 1 / 0;
            callBack.onExecute(data);
        } catch (Exception e) {
            callBack.onError(data);
            throw new RuntimeException(e);
        }
    }
}
